#include <iostream>
#include <vector>
using namespace std;

int ret = 0;
void backtrace(vector<vector<char> >& s,int x,int y){
    if(x < 0 || y < 0 || x >= s.size() || y >= s[0].size() || s[x][y] == '#'){
        return;
    }
    s[x][y] = '#';
    backtrace(s,x+1,y);
    backtrace(s,x-1,y);
    backtrace(s,x,y+1);
    backtrace(s,x,y-1);   
    ret++;
}
int main(){
    int m,n;
    int x,y;
    while(cin>>m>>n){
        vector<vector<char> > s(m,vector<char>(n,'x'));
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                cin>>s[i][j];
                if(s[i][j] == '@'){
                    x = i;
                    y = j;
                }
            }
        }
        backtrace(s,x,y);
        cout<<ret<<endl;
        ret = 0;
    }
    
    return 0;
}
